<template>
  <div class="tutorial-home">
    <div class="header animated fadeInDown">
      <h1 class="main-title">Vue 3 完全教程</h1>
      <p class="subtitle">从基础到进阶，全面掌握 Vue 3 开发技能</p>
    </div>

    <div class="content">
      <div class="topics-grid">
        <div 
          class="topic-card animated fadeInUp" 
          v-for="(topic, index) in topics" 
          :key="topic.id" 
          @click="goToTopic(topic.path)"
          :style="{ animationDelay: index * 0.1 + 's' }"
        >
          <div class="topic-icon">
            <i :class="topic.icon"></i>
          </div>
          <h3>{{ topic.title }}</h3>
          <p>{{ topic.description }}</p>
          <div class="card-overlay"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { ref, onMounted } from 'vue'

const router = useRouter()

const topics = ref([
  {
    id: 1,
    title: 'Vue 创建',
    path: '/creation',
    icon: 'fas fa-plus-circle',
    description: 'Vue CLI 和 Vite 创建项目，项目结构解析'
  },
  {
    id: 2,
    title: '生命周期',
    path: '/lifecycle',
    icon: 'fas fa-sync-alt',
    description: 'Vue 3 生命周期钩子详解'
  },
  {
    id: 3,
    title: '指令',
    path: '/directives',
    icon: 'fas fa-code',
    description: '内置指令和自定义指令'
  },
  {
    id: 4,
    title: '组件',
    path: '/components',
    icon: 'fas fa-puzzle-piece',
    description: '组件基础、Props、事件、插槽'
  },
  {
    id: 5,
    title: '计算属性',
    path: '/computed',
    icon: 'fas fa-calculator',
    description: '计算属性和侦听器'
  },
  {
    id: 6,
    title: '样式绑定',
    path: '/styling',
    icon: 'fas fa-palette',
    description: 'Class 与 Style 绑定'
  },
  {
    id: 7,
    title: '混入',
    path: '/mixins',
    icon: 'fas fa-copy',
    description: '混入机制和使用场景'
  },
  {
    id: 8,
    title: '组合式API',
    path: '/composition',
    icon: 'fas fa-layer-group',
    description: 'Composition API 基础和进阶'
  },
  {
    id: 9,
    title: 'Vue Router',
    path: '/router',
    icon: 'fas fa-route',
    description: '路由配置和导航'
  },
  {
    id: 10,
    title: 'Axios',
    path: '/axios',
    icon: 'fas fa-network-wired',
    description: 'HTTP 请求和数据交互'
  },
  {
    id: 11,
    title: 'Element Plus',
    path: '/elementplus',
    icon: 'fas fa-box-open',
    description: 'Element Plus 组件库使用'
  }
])

const goToTopic = (path) => {
  router.push(path)
}

// 添加页面加载动画
onMounted(() => {
  document.querySelector('.tutorial-home').classList.add('animated', 'fadeIn')
})
</script>

<style scoped>
.tutorial-home {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

.header {
  text-align: center;
  margin-bottom: 4rem;
  padding: 2rem;
}

.main-title {
  font-size: 3.5rem;
  color: #2c3e50;
  margin-bottom: 1.5rem;
  font-weight: 800;
  background: linear-gradient(45deg, #42b883, #35495e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.subtitle {
  font-size: 1.4rem;
  color: #666;
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2.5rem;
}

.topic-card {
  background: white;
  border-radius: 15px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(66, 184, 131, 0.1);
}

.topic-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.topic-card:hover .card-overlay {
  opacity: 1;
}

.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, rgba(66, 184, 131, 0.1), rgba(53, 73, 94, 0.1));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.topic-icon {
  font-size: 3rem;
  color: #42b883;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.topic-card:hover .topic-icon {
  transform: scale(1.2) rotate(5deg);
}

.topic-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1.2rem;
  color: #2c3e50;
  position: relative;
  z-index: 1;
}

.topic-card p {
  color: #666;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

@media (max-width: 1024px) {
  .topics-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
  }
  
  .main-title {
    font-size: 2.8rem;
  }
}

@media (max-width: 768px) {
  .tutorial-home {
    padding: 2rem 1rem;
  }
  
  .header {
    margin-bottom: 3rem;
    padding: 1rem;
  }
  
  .main-title {
    font-size: 2.2rem;
  }
  
  .subtitle {
    font-size: 1.1rem;
  }
  
  .topics-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .topic-card {
    padding: 2rem 1.5rem;
  }
}
</style>